/*The Circle class is used for drawing each circle pattern
It calculates dots position along the periphery
*/

class Circle{
  PVector location;  //circle center location
  float radius;
  int weight;  //stroke weight, the larger, the thicker
  int step;  // dots number for each circle, increase the number will increase the density of dots
  PVector[] vectorArray;  //store all dots location
  
  Circle (float x, float y, float r, int w) {
    step = 36;  //default step number is 36, (360/10)
    vectorArray = new PVector[step];
    location = new PVector(x,y);
    radius = r;
    weight = w;
    calculateVectorArray();
  }
  
  void calculateVectorArray() {  //calculate all dots position
    for (int i=0;i<step;i++) {
      float tempx = location.x + (radius * cos(i * PI * 2 / step));
      float tempy = location.y + (radius * sin(i * PI * 2 / step));
      vectorArray[i] = new PVector(tempx, tempy);  //store dots position to an array
    }    
  }
  
  void draw(int t) {  //three drawing modes. 0: only draw strokes. 1: only draw dots. 2: draw both
    if(t==0) {
      drawPatterns();
    }
    else if(t==1)
    {
      drawDots();
    }
    else
    {
      drawPatterns();
      drawDots();
    }
  }
  
  void drawPatterns() {  //draw strokes
      noFill();
      strokeWeight(weight);
      stroke(0);
      ellipse(location.x,location.y,radius*2,radius*2);
  }
  
  void drawDots() {    //draw dots
      noStroke();
      fill(255,0,0);
      calculateVectorArray();  //calculate the current dots position
      for(int i=0; i<step; i++) {  //draw all dots
        ellipse(vectorArray[i].x, vectorArray[i].y, weight*1.5,weight*1.5);  //dots's radius is based on the circle stroke
      }
  }
}
